#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int cmp(const int& x, const int& y)
{
	return x > y;
}
int greedStrategy(vector<int>& machines, vector<int>& works)
{
	int n = machines.size();
	int m = works.size();
	sort(works.begin(), works.end(), cmp);
	for (int i = 0; i < m; i++)
	{
		machines[0] += works[i];
		sort(machines.begin(), machines.end());
	}

	return machines[n - 1];
}


int main()
{
	vector<int> machines(3);
	vector<int> works{ 9,6,7,8,3,4,6,2,1};
	cout << greedStrategy(machines, works) << endl;
	return 0;
}